
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>js中获取时间new Date()详细介绍 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="less传参问题：在url中插入变量今天在需要用less给url传递参数时遇到了小问题，一番搜索后有了下述解决方法.html" />
    
    
    <link rel="prev" href="JS数组reduce方法详解及高级技巧.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../cmd命令.html">
            
                <a href="../cmd命令.html">
            
                    
                    cmd命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="Array.prototype.slice.call.html">
            
                <a href="Array.prototype.slice.call.html">
            
                    
                    Array.prototype.slice.call解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="async 函数.html">
            
                <a href="async 函数.html">
            
                    
                    async 函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="callback&&callback如果存在回调函数就执行.html">
            
                <a href="callback&&callback如果存在回调函数就执行.html">
            
                    
                    callback&&callback() 如果存在回调函数就执行！
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="CSS3 nth-child使用注意.html">
            
                <a href="CSS3 nth-child使用注意.html">
            
                    
                    CSS3 nth-child(n)使用注意
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="css3的 -webkit-min-device-pixel-ratio属性 解决高清的适配.html">
            
                <a href="css3的 -webkit-min-device-pixel-ratio属性 解决高清的适配.html">
            
                    
                    css3的 -webkit-min-device-pixel-ratio属性 解决高清的适配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="CSS文本超出自动缩小字体.html">
            
                <a href="CSS文本超出自动缩小字体.html">
            
                    
                    CSS文本超出自动缩小字体
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="element-ui默认样式修改.html">
            
                <a href="element-ui默认样式修改.html">
            
                    
                    element-ui默认样式修改
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="JavaScript setInterval函数详解.html">
            
                <a href="JavaScript setInterval函数详解.html">
            
                    
                    JavaScript setInterval() 函数详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="JavaScript概念之screenclientoffsetscrollinneravail的widthleft.html">
            
                <a href="JavaScript概念之screenclientoffsetscrollinneravail的widthleft.html">
            
                    
                    JavaScript概念之screenclientoffsetscrollinneravail的widthleft
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="js获取星期几.html">
            
                <a href="js获取星期几.html">
            
                    
                    js获取星期几
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="js监听滚动条事件和获取浏览器及屏幕高度和宽度等信息的方法.html">
            
                <a href="js监听滚动条事件和获取浏览器及屏幕高度和宽度等信息的方法.html">
            
                    
                    js监听滚动条事件和获取浏览器及屏幕高度和宽度等信息的方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="js时间戳与日期格式之间相互转换.html">
            
                <a href="js时间戳与日期格式之间相互转换.html">
            
                    
                    js时间戳与日期格式之间相互转换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="JS数组reduce方法详解及高级技巧.html">
            
                <a href="JS数组reduce方法详解及高级技巧.html">
            
                    
                    JS数组reduce()方法详解及高级技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.16" data-path="js中获取时间new Date详细介绍.html">
            
                <a href="js中获取时间new Date详细介绍.html">
            
                    
                    js中获取时间new Date()详细介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="less传参问题：在url中插入变量今天在需要用less给url传递参数时遇到了小问题，一番搜索后有了下述解决方法.html">
            
                <a href="less传参问题：在url中插入变量今天在需要用less给url传递参数时遇到了小问题，一番搜索后有了下述解决方法.html">
            
                    
                    less传参问题：在url中插入变量今天在需要用less给url传递参数时遇到了小问题，一番搜索后有了下述解决方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="moment 和date-fns.html">
            
                <a href="moment 和date-fns.html">
            
                    
                    moment 和date-fns
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="node.JS中配置http-server.html">
            
                <a href="node.JS中配置http-server.html">
            
                    
                    node.JS中配置http-server
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="Object.keys详解.html">
            
                <a href="Object.keys详解.html">
            
                    
                    Object.keys详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="router-link各种属性解释.html">
            
                <a href="router-link各种属性解释.html">
            
                    
                    router-link各种属性解释
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="stylus使用介绍.html">
            
                <a href="stylus使用介绍.html">
            
                    
                    stylus使用介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="TypeError Cannot read property 'compilation' of undefined.html">
            
                <a href="TypeError Cannot read property 'compilation' of undefined.html">
            
                    
                    TypeError Cannot read property 'compilation' of undefined
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.24" data-path="Vue  keep-alive.html">
            
                <a href="Vue  keep-alive.html">
            
                    
                    Vue  keep-alive
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.25" data-path="Vue - 过渡与动画transition.html">
            
                <a href="Vue - 过渡与动画transition.html">
            
                    
                    Vue - 过渡与动画transition
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.26" data-path="vue-axios使用方法.html">
            
                <a href="vue-axios使用方法.html">
            
                    
                    vue-axios使用方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.27" data-path="vue-calendar-component.html">
            
                <a href="vue-calendar-component.html">
            
                    
                    vue-calendar-component
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.28" data-path="vue-infinite-loading.html">
            
                <a href="vue-infinite-loading.html">
            
                    
                    vue-infinite-loading
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.29" data-path="vue报错There are multiple modules with names that only differ in casing.html">
            
                <a href="vue报错There are multiple modules with names that only differ in casing.html">
            
                    
                    vue报错There are multiple modules with names that only differ in casing
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.30" data-path="Vue中注意target和currentTarget的使用.html">
            
                <a href="Vue中注意target和currentTarget的使用.html">
            
                    
                    Vue中注意target和currentTarget的使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.31" data-path="关于给javascript对象添加、删除、修改对象的属性.html">
            
                <a href="关于给javascript对象添加、删除、修改对象的属性.html">
            
                    
                    关于给javascript对象添加、删除、修改对象的属性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.32" data-path="获取当前地址坐标.html">
            
                <a href="获取当前地址坐标.html">
            
                    
                    获取当前地址坐标
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.33" data-path="解决ajax跨域问题【5种解决方案】.html">
            
                <a href="解决ajax跨域问题【5种解决方案】.html">
            
                    
                    解决ajax跨域问题【5种解决方案】
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.34" data-path="解决vue-cli webpack打包后加载资源的路径问题.html">
            
                <a href="解决vue-cli webpack打包后加载资源的路径问题.html">
            
                    
                    解决vue-cli webpack打包后加载资源的路径问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.35" data-path="时间格式转换：201971转换为2019-7-1.html">
            
                <a href="时间格式转换：201971转换为2019-7-1.html">
            
                    
                    时间格式转换：201971转换为2019-7-1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.36" data-path="数据库密码改了.html">
            
                <a href="数据库密码改了.html">
            
                    
                    数据库密码改了
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.37" data-path="语法getBoundingClientRect.html">
            
                <a href="语法getBoundingClientRect.html">
            
                    
                    语法getBoundingClientRect()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.38" data-path="在js中使用length报错Error in renderTypeErrorcannot read property bgImg of null.html">
            
                <a href="在js中使用length报错Error in renderTypeErrorcannot read property bgImg of null.html">
            
                    
                    在js中使用length报错Error in renderTypeErrorcannot read property bgImg of null
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >js中获取时间new Date()详细介绍</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="js&#x4E2D;&#x83B7;&#x53D6;&#x65F6;&#x95F4;new-date&#x8BE6;&#x7EC6;&#x4ECB;&#x7ECD;">js&#x4E2D;&#x83B7;&#x53D6;&#x65F6;&#x95F4;new Date()&#x8BE6;&#x7EC6;&#x4ECB;&#x7ECD;</h1>
<p>&#x200B;                                                                                                                         2018&#x5E74;08&#x6708;03&#x65E5; 16:59:22                     <a href="https://me.csdn.net/mning199201" target="_blank">mini&#x767D;</a>                     &#x9605;&#x8BFB;&#x6570; 2405                                     </p>
<p>&#x200B;                                     </p>
<p>var myDate = new Date();
 myDate.getYear(); //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x5E74;&#x4EFD;(2&#x4F4D;)
 myDate.getFullYear(); //&#x83B7;&#x53D6;&#x5B8C;&#x6574;&#x7684;&#x5E74;&#x4EFD;(4&#x4F4D;,1970-????)
 myDate.getMonth(); //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x6708;&#x4EFD;(0-11,0&#x4EE3;&#x8868;1&#x6708;)         // &#x6240;&#x4EE5;&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x6708;&#x4EFD;&#x662F;myDate.getMonth()+1; 
 myDate.getDate(); //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x65E5;(1-31)
 myDate.getDay(); //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x661F;&#x671F;X(0-6,0&#x4EE3;&#x8868;&#x661F;&#x671F;&#x5929;)
 myDate.getTime(); //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x65F6;&#x95F4;(&#x4ECE;1970.1.1&#x5F00;&#x59CB;&#x7684;&#x6BEB;&#x79D2;&#x6570;)
 myDate.getHours(); //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x5C0F;&#x65F6;&#x6570;(0-23)
 myDate.getMinutes(); //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x5206;&#x949F;&#x6570;(0-59)
 myDate.getSeconds(); //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x79D2;&#x6570;(0-59)
 myDate.getMilliseconds(); //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x6BEB;&#x79D2;&#x6570;(0-999)
<strong><em>myDate.toLocaleDateString(); //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x65E5;&#x671F;  (&#x7ECF;&#x5E38;&#x548C;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7ED3;&#x5408;&#x4F7F;&#x7528;&#x6765;&#x6539;&#x53D8;&#x65E5;&#x671F;&#x683C;&#x5F0F;)</em></strong>
 var mytime=myDate.toLocaleTimeString(); //&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x65F6;&#x95F4;
 myDate.toLocaleString( ); //&#x83B7;&#x53D6;&#x65E5;&#x671F;&#x4E0E;&#x65F6;&#x95F4;</p>
<p>==========================================================================</p>
<p>JS&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x65F6;&#x95F4;&#x6233;&#x7684;&#x65B9;&#x6CD5;-JavaScript &#x83B7;&#x53D6;&#x5F53;&#x524D;&#x6BEB;&#x79D2;&#x65F6;&#x95F4;&#x6233;&#x6709;&#x4EE5;&#x4E0B;&#x4E09;&#x79CD;&#x65B9;&#x6CD5;&#xFF1A;</p>
<p>var timestamp =Date.parse(new Date());    &#x7ED3;&#x679C;&#xFF1A;1280977330000       //&#x4E0D;&#x63A8;&#x8350;; &#x6BEB;&#x79D2;&#x6539;&#x6210;&#x4E86;000&#x663E;&#x793A;</p>
<p>var timestamp =(new Date()).valueOf();       &#x7ED3;&#x679C;&#xFF1A;1280977330748       //&#x63A8;&#x8350;; </p>
<p>var timestamp=new Date().getTime();         &#x7ED3;&#x679C;&#xFF1A;1280977330748        //&#x63A8;&#x8350;; </p>
<p>js&#x4E2D;&#x5355;&#x72EC;&#x8C03;&#x7528;new Date();  &#x663E;&#x793A;&#x8FD9;&#x79CD;&#x683C;&#x5F0F;  Mar 31 10:10:43 UTC+0800 2012</p>
<p>&#x4F46;&#x662F;&#x7528;new Date() &#x53C2;&#x4E0E;&#x8BA1;&#x7B97;&#x4F1A;&#x81EA;&#x52A8;&#x8F6C;&#x6362;&#x4E3A;&#x4ECE;1970.1.1&#x5F00;&#x59CB;&#x7684;&#x6BEB;&#x79D2;&#x6570;</p>
<p>--------------------------------------------------------------------------------------------------</p>
<p><strong>&#x5C06;&#x5B57;&#x7B26;&#x4E32;&#x5F62;&#x5F0F;&#x7684;&#x65E5;&#x671F;&#x8F6C;&#x6362;&#x6210;&#x65E5;&#x671F;&#x5BF9;&#x8C61;</strong></p>
<p>var strTime=&quot;2011-04-16&quot;;    //&#x5B57;&#x7B26;&#x4E32;&#x65E5;&#x671F;&#x683C;&#x5F0F;<br> var date= new Date(Date.parse(strTime.replace(/-/g,  &quot;/&quot;)));      //&#x8F6C;&#x6362;&#x6210;Data();</p>
<p>--------------------------------------------------------------------------------------------------</p>
<p>new Date() ;     //&#x53C2;&#x6570;&#x53EF;&#x4EE5;&#x4E3A;&#x6574;&#x6570;; &#x4E5F;&#x53EF;&#x4EE5;&#x4E3A;&#x5B57;&#x7B26;&#x4E32;; &#x4F46;&#x683C;&#x5F0F;&#x5FC5;&#x987B;&#x6B63;&#x786E;</p>
<p>new Date(2009,1,1);       //&#x6B63;&#x786E;</p>
<p>new Date(&quot;2009/1/1&quot;);    //&#x6B63;&#x786E;</p>
<p>new Date(&quot;2009-1-1&quot;);    //&#x9519;&#x8BEF;</p>
<p>new Date( year, month, date, hrs, min, sec)  &#x6309;&#x7ED9;&#x5B9A;&#x7684;&#x53C2;&#x6570;&#x521B;&#x5EFA;&#x4E00;&#x65E5;&#x671F;&#x5BF9;&#x8C61;
 &#x3000;&#x3000;&#x53C2;&#x6570;&#x8BF4;&#x660E;&#xFF1A;
 &#x3000;&#x3000;year&#x7684;&#x503C;&#x4E3A;&#xFF1A;&#x9700;&#x8BBE;&#x5B9A;&#x7684;&#x5E74;&#x4EFD;-1900&#x3002;&#x4F8B;&#x5982;&#x9700;&#x8BBE;&#x5B9A;&#x7684;&#x5E74;&#x4EFD;&#x662F;1997&#x5219;year&#x7684;&#x503C;&#x5E94;&#x4E3A;97&#xFF0C;&#x5373;1997-1900&#x7684;&#x7ED3;&#x679C;&#x3002;&#x6240;&#x4EE5;Date&#x4E2D;&#x53EF;&#x8BBE;&#x5B9A;&#x7684;&#x5E74;&#x4EFD;&#x6700;&#x5C0F;&#x4E3A;1900&#xFF1B;
 &#x3000;&#x3000;month&#x7684;&#x503C;&#x57DF;&#x4E3A;0&#xFF5E;11&#xFF0C;0&#x4EE3;&#x8868;1&#x6708;&#xFF0C;11&#x8868;&#x4EE3;&#x8868;12&#x6708;&#xFF1B;
 &#x3000;&#x3000;date&#x7684;&#x503C;&#x57DF;&#x5728;1&#xFF5E;31&#x4E4B;&#x95F4;&#xFF1B;
 &#x3000;&#x3000;hrs&#x7684;&#x503C;&#x57DF;&#x5728;0&#xFF5E;23&#x4E4B;&#x95F4;&#x3002;&#x4ECE;&#x5348;&#x591C;&#x5230;&#x6B21;&#x65E5;&#x51CC;&#x6668;1&#x70B9;&#x95F4;hrs=0&#xFF0C;&#x4ECE;&#x4E2D;&#x5348;&#x5230;&#x4E0B;&#x5348;1&#x70B9;&#x95F4;hrs=12&#xFF1B;
 &#x3000;&#x3000;min&#x548C;sec&#x7684;&#x503C;&#x57DF;&#x5728;0&#xFF5E;59&#x4E4B;&#x95F4;&#x3002;
 &#x3000;&#x3000;&#x4F8B; Date day=new Date(11,3,4);
 &#x3000;&#x3000;//day&#x4E2D;&#x7684;&#x65F6;&#x95F4;&#x4E3A;&#xFF1A;04-Apr-11 12:00:00 AM</p>
<pre><code>    &#x53E6;&#x5916;&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x7ED9;&#x51FA;&#x4E0D;&#x6B63;&#x786E;&#x7684;&#x53C2;&#x6570;&#x3002;
</code></pre><p> &#x3000;&#x3000;&#x4F8B;&#x3000;&#x8BBE;&#x5B9A;&#x65F6;&#x95F4;&#x4E3A;1910&#x5E74;2&#x6708;30&#x65E5;&#xFF0C;&#x5B83;&#x5C06;&#x88AB;&#x89E3;&#x91CA;&#x6210;3&#x6708;2&#x65E5;&#x3002;
 &#x3000;&#x3000;Date day=new Date(10,1,30,10,12,34);
 &#x3000;&#x3000;System.out.println(&quot;Day&apos;s date is:&quot;+day);
 &#x3000;&#x3000;//&#x6253;&#x5370;&#x7ED3;&#x679C;&#x4E3A;&#xFF1A;Day&apos;s date is:Web Mar 02 10:13:34 GMT+08:00 1910</p>
<p>--------------------------------------------------------------------------------------------------</p>
<p>1&#x3001;&#x5F53;&#x524D;&#x7CFB;&#x7EDF;&#x533A;&#x57DF;&#x8BBE;&#x7F6E;&#x683C;&#x5F0F;(toLocaleDateString&#x548C;toLocaleTimeString)</p>
<p>&#x200B;     &#x4F8B;&#x5B50;:(new Date()).toLocaleDateString() + &quot; &quot; + (new Date()).toLocaleTimeString()
&#x200B;      &#x7ED3;&#x679C;: 2008&#x5E74;1&#x6708;29&#x65E5; 16:13:11</p>
<p>2.&#x666E;&#x901A;&#x5B57;&#x7B26;&#x4E32;(toDateString&#x548C;toTimeString)</p>
<p>&#x200B;     &#x4F8B;&#x5B50;: (new Date()).toDateString() + &quot; &quot; + (new Date()).toTimeString()
&#x200B;      &#x7ED3;&#x679C;:Tue Jan 29 2008 16:13:11 UTC+0800</p>
<p>3.&#x683C;&#x6797;&#x5A01;&#x6CBB;&#x6807;&#x51C6;&#x65F6;&#x95F4;(toGMTString)</p>
<p>&#x200B;     &#x4F8B;&#x5B50;: (new Date()).toGMTString()
&#x200B;      &#x7ED3;&#x679C;:Tue, 29 Jan 2008 08:13:11 UTC</p>
<p>4.&#x5168;&#x7403;&#x6807;&#x51C6;&#x65F6;&#x95F4;(toUTCString)</p>
<p>&#x200B;     &#x4F8B;&#x5B50;: (new Date()).toUTCString()
&#x200B;      &#x7ED3;&#x679C;:Tue, 29 Jan 2008 08:13:11 UTC</p>
<p>5.Date&#x5BF9;&#x8C61;&#x5B57;&#x7B26;&#x4E32;(toString)</p>
<p>&#x200B;     &#x4F8B;&#x5B50;: (new Date()).toString()
&#x200B;      &#x7ED3;&#x679C;:Tue Jan 29 16:13:11 UTC+0800 2008</p>
<p>--------------------------------------------------------------------------------------------------</p>
<p>&#x65E5;&#x671F;&#x5BF9;&#x8C61;&#x4E5F;&#x53EF;&#x7528;&#x4E8E;&#x6BD4;&#x8F83;&#x4E24;&#x4E2A;&#x65E5;&#x671F;&#x3002;</p>
<p>&#x200B;     var myDate=new Date(); myDate.setFullYear(2008,7,9);</p>
<p>&#x200B;     var today = new Date();</p>
<p>&#x200B;     if (myDate&gt;today){</p>
<p>&#x200B;         ......;</p>
<p>&#x200B;      }</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="JS数组reduce方法详解及高级技巧.html" class="navigation navigation-prev " aria-label="Previous page: JS数组reduce()方法详解及高级技巧">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="less传参问题：在url中插入变量今天在需要用less给url传递参数时遇到了小问题，一番搜索后有了下述解决方法.html" class="navigation navigation-next " aria-label="Next page: less传参问题：在url中插入变量今天在需要用less给url传递参数时遇到了小问题，一番搜索后有了下述解决方法">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"js中获取时间new Date()详细介绍","level":"1.16","depth":1,"next":{"title":"less传参问题：在url中插入变量今天在需要用less给url传递参数时遇到了小问题，一番搜索后有了下述解决方法","level":"1.17","depth":1,"path":"project/less传参问题：在url中插入变量今天在需要用less给url传递参数时遇到了小问题，一番搜索后有了下述解决方法.md","ref":"project/less传参问题：在url中插入变量今天在需要用less给url传递参数时遇到了小问题，一番搜索后有了下述解决方法.md","articles":[]},"previous":{"title":"JS数组reduce()方法详解及高级技巧","level":"1.15","depth":1,"path":"project/JS数组reduce方法详解及高级技巧.md","ref":"project/JS数组reduce方法详解及高级技巧.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"project/js中获取时间new Date详细介绍.md","mtime":"2019-07-05T04:23:21.266Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-07-18T03:07:23.077Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

